package com.wealth.bank.web.controller;

import iaas.enums.StatusEnum;
import iaas.utils.ResultObject;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wealth.bank.entity.Branch;
import com.wealth.bank.service.IArticleCategoryService;
import com.wealth.bank.service.IArticleService;
import com.wealth.bank.service.IBranchService;
import com.wealth.page.service.IADService;
import com.wealth.system.web.controller.BaseController;


/**
 * 银行网点
 * @author Administrator
 */


@Controller
@RequestMapping(value="/branch")
public class BranchController  extends BaseController{
	Logger logger = Logger.getLogger(BranchController.class);
	
	@Autowired
	private IArticleCategoryService categoryService;
	@Autowired
	private IArticleService articleService;
	@Autowired
	private IADService adService;
	@Autowired
	private IBranchService branchService;
	
	
	
	/**
	 * 查询页面
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/query",method=RequestMethod.GET)
	public String query(HttpServletRequest request, Model model) {
		
		try {
			return "branch/branch";
		} catch (Exception e) {
			logger.error(e);
			return "system/500";
		}
	}
	
	/**
	 * 查询页面
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/map",method=RequestMethod.POST)
	@ResponseBody
	public ResultObject map(HttpServletRequest request, Model model,@RequestParam String address) {
		
		try {
			List<Branch> branchs=branchService.findByCorpIdAndStatusAndAddressLike(corpid, StatusEnum.NORMAL.getValue(),address);
			return new ResultObject("000","", branchs);
		} catch (Exception e) {
			logger.error(e);
			return new ResultObject("999","", "");
		}
	}
	


}
